package main

import (
	"fmt"
	"reflect"
)

func main17() {
	slice := make([]interface{}, 10)
	map1 := make(map[string]string)
	map2 := make(map[string]int)
	map2["TaskID"] = 1
	map1["Command"] = "ping"
	map3 := make(map[string]map[string]string)
	map3["mapValue"] = map1
	slice[0] = map2
	slice[1] = map1
	slice[3] = map3
	fmt.Println(slice[0])
	fmt.Println(slice[1])
	fmt.Println(slice[3])

	var circle float64 = 6.28
	var cir interface{}

	cir = circle
	fmt.Println("Reflect : circle.Value = ", reflect.ValueOf(cir))
	fmt.Println("Reflect : circle.Type  = ", reflect.TypeOf(cir))
	fmt.Println("Reflect : circle.Value = ", reflect.ValueOf(circle))
	fmt.Println("Reflect : circle.Type  = ", reflect.TypeOf(circle))

	valueRef := reflect.ValueOf(cir)
	fmt.Println(valueRef)
	fmt.Println(valueRef.Interface())

	y := valueRef.Interface().(float64)
	fmt.Println(y)

	value := reflect.ValueOf(circle)
	fmt.Println("Reflect : value = ", value)
	// CanSet函数确认变量是否是可修改的
	fmt.Println("Settability of value : ", value.CanSet())

	value2 := reflect.ValueOf(&circle)
	fmt.Println("Settability of value : ", value2.CanSet())

	value3 := value2.Elem()
	fmt.Println("Settability of value : ", value3.CanSet())

	value3.SetFloat(3.14)
	fmt.Println("Value of value3: ", value3)
	fmt.Println("value of circle: ", circle)
}
